import Foundation

enum AppError: Error, LocalizedError {
    case network(underlying: URLError)
    case decoding(underlying: DecodingError)
    case server(statusCode: Int)
    case unknown(message: String)

    var errorDescription: String? {
        switch self {
        case .network:
            return "网络请求失败，请稍后重试。"
        case .decoding:
            return "数据解析失败。"
        case .server(let statusCode):
            return "服务器错误（\(statusCode)）。"
        case .unknown(let message):
            return message
        }
    }
}


